package cn.edu.neusoft.yyd208.foodorder.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.yyd208.foodorder.activity.FoodListActivity;
import cn.edu.neusoft.yyd208.foodorder.bean.ShopBean;

import static android.media.CamcorderProfile.get;



public class ShopAdapter extends BaseAdapter<ShopBean>{


    public ShopAdapter(Context context, List<ShopBean> items, int layoutResource) {
        super(context, items, layoutResource);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        ShopViewHolder myViewHolder=(ShopViewHolder)holder;
        final String id=items.get(position).getShop_id();
        final String shopname=items.get(position).getShopname();
        final String intro=items.get(position).getIntro();
        String shopaddress=items.get(position).getAddress();
        myViewHolder.tv_shop.setText(shopname);
        myViewHolder.tv_address.setText(shopaddress);
        myViewHolder.tv_intro.setText(intro);
        Picasso.with(context).load( "http://172.24.10.175:8080/foodService" + items.get(position).getPic()).into(myViewHolder.img_shop);
        myViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("TEST", "onClick: ");
                Intent intent=new Intent(context, FoodListActivity.class);
                intent.putExtra("id",id);
                intent.putExtra("shopname",shopname);
                context.startActivity(intent);
            }
        });

    }


}
